# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

_realname=libiconv

pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.14
pkgrel=2
pkgdesc='Libiconv is a conversion library'
groups=("${MINGW_PACKAGE_PREFIX}")
arch=('any')
url='http://www.gnu.org/software/libiconv/'
license=('LGPL')
source=("http://ftp.gnu.org/pub/gnu/${_realname}/${_realname}-${pkgver}.tar.gz"
        0001-compile-relocatable-in-gnulib.mingw.patch
        0002-fix-cr-for-awk-in-configure.all.patch)
md5sums=('e34509b1623cec449dfeb73d7ce9c6c6'
         '8818b7fe31286f589d180713329eb893'
         '9e955ee7135d39970a086451d4b87520')
options=('!libtool' 'staticlibs')

prepare() {
  cd $srcdir/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-compile-relocatable-in-gnulib.mingw.patch
  patch -p1 -i ${srcdir}/0002-fix-cr-for-awk-in-configure.all.patch
}

build() {
  cd $srcdir/${_realname}-${pkgver}
  ./configure --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared \
    --enable-extra-encodings \
    --enable-relocatable \
    --disable-rpath \
    --enable-silent-rules \
    --enable-nls
  make
}

check() {
  cd ${srcdir}/${_realname}-${pkgver}
  make check
}

package() {
  cd ${srcdir}/${_realname}-${pkgver}
  make install DESTDIR="${pkgdir}"
  rm -f ${pkgdir}${MINGW_PREFIX}/lib/charset.alias
}
